// LedDot.cpp: implementation of the CLedDot class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "8085.h"
#include "LedDot.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CLedDot::CLedDot()
{

}

CLedDot::~CLedDot()
{

}


void CLedDot::Create(int XPos,int  YPos,int nLen,int nWidth,int nAngle)
{
    // radius of the dot.
    m_Points.x = XPos;
    m_Points.y = YPos;
    m_nLEDSegmentLength=nLen<0?8:nLen;
    m_nLEDSegmentWidth=nWidth<0?8:nWidth;
}

void CLedDot::Create(CPoint p,int nLen,int nWidth,int nAngle)
{
    Create(p.x,p.y,nLen,nWidth,nAngle);
}


void CLedDot::Draw(CDC *pDC,unsigned nState)
{
    Draw(pDC,nState?m_LedOn:m_LedOff);
}


void CLedDot::Draw(CDC *pDC,COLORREF color)
{
    // state represents on or off state of the LED
    CBrush fill(color);
    CPen pen(PS_SOLID,1,color);
    // install the brush and pen and get the previous brush and pen
    // to be restored later 
    CPen *savePen = pDC->SelectObject(&pen);
    CBrush *saveBrush = pDC->SelectObject(&fill);

    CPoint p(m_Points.x+m_nLEDSegmentLength,m_Points.y+m_nLEDSegmentWidth);
    pDC->Ellipse(m_Points.x,m_Points.y,p.x,p.y);

    // restore the saved pen and brush
    pDC->SelectObject(savePen);
    pDC->SelectObject(saveBrush);    // restore the saved brush
}



/////////////////////////////////////////////
// Implementation of empty LED
//

CLedEmpty::CLedEmpty()
{
    
}

CLedEmpty::~CLedEmpty()
{

}


void CLedEmpty::Create(int XPos,int  YPos,int nLen,int nWidth,int nAngle)
{
    m_Points.x = XPos;
    m_Points.y = YPos;
    m_nLEDSegmentLength=nLen<0?8:nLen;
    m_nLEDSegmentWidth=nWidth<0?8:nWidth;
    m_bEmptyLed = TRUE;
}

void CLedEmpty::Create(CPoint p,int nLen,int nWidth,int nAngle)
{
    Create(p.x,p.y,nLen,nWidth,nAngle);
}


void CLedEmpty::Draw(CDC *pDC,unsigned nState)
{
    Draw(pDC,nState?m_LedOn:m_LedOff);
}


void CLedEmpty::Draw(CDC *pDC,COLORREF color)
{

}

